// Mimics the "grab" icon with CSS psuedo-elements.
// The "grab" icon transforms into a 2px straight line on :hover and :focus.
.euiResizableButton {
  position: relative;
  flex-shrink: 0;

  &:before,
  &:after {
    content: '';
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    background-color: $euiColorDarkestShade;
    transition: (
      width $euiResizableButtonTransitionSpeed ease,
      height $euiResizableButtonTransitionSpeed ease,
      transform $euiResizableButtonTransitionSpeed ease,
      background-color $euiResizableButtonTransitionSpeed ease
    );
  }

  &.euiResizableButton--horizontal {
    cursor: col-resize;

    &:before,
    &:after {
      width: 1px;
      height: 12px;
    }

    &:before {
      transform: translate(-2px, -50%);
    }

    &:after {
      transform: translate(1px, -50%);
    }
  }

  &.euiResizableButton--vertical {
    cursor: row-resize;

    &:before,
    &:after {
      width: 12px;
      height: 1px;
    }

    &:before {
      transform: translate(-50%, -2px);
    }

    &:after {
      transform: translate(-50%, 1px);
    }
  }

  //Lighten the "grab" icon on :hover
  &:hover {
    &:before,
    &:after {
      background-color: $euiColorMediumShade;
      transition-delay: $euiResizableButtonTransitionSpeed; //Delay transition on hover so animation is not accidentally triggered on mouse over
    }
  }

  //Add a transparent background to the container and emphasis the "grab" icon with primary color on :focus
  &:focus {
    background-color: transparentize($euiColorPrimary, 0.9);

    &:before,
    &:after {
      background-color: $euiColorPrimary;
      // Overrides default transition so that "grab" icon background-color doesn't animate
      transition: (
        width $euiResizableButtonTransitionSpeed ease,
        height $euiResizableButtonTransitionSpeed ease,
        transform $euiResizableButtonTransitionSpeed ease
      );
      transition-delay: $euiResizableButtonTransitionSpeed / 2;
    }
  }

  //Morph the "grab" icon into a fluid 2px straight line on :hover and :focus
  &:hover,
  &:focus {
    &.euiResizableButton--horizontal {
      &:before,
      &:after {
        height: 100%;
      }

      &:before {
        transform: translate(-1px, -50%);
      }

      &:after {
        transform: translate(0, -50%);
      }
    }

    &.euiResizableButton--vertical {
      &:before,
      &:after {
        width: 100%;
      }

      &:before {
        transform: translate(-50%, -1px);
      }

      &:after {
        transform: translate(-50%, 0);
      }
    }
  }
}

//Generate modifier classes that control the size of the resizer
@each $modifier, $amount in $euiResizableButtonSizeModifiers {
  .euiResizableButton--#{$modifier} {
    &.euiResizableButton--vertical {
      height: $amount;
    }

    &.euiResizableButton--horizontal {
      width: $amount;
    }
  }
}
